<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>推送过来的消息列表</title>
    <script type="text/javascript" src="./jquery-1.12.4.js"></script>
</head>
<body>
<ul class="message">
    <li>初始值</li>
</ul>
</body>
<script>
$(function () {
//创建websocket客户端
    var ws=new WebSocket("ws://10.211.55.6:9501");
//当客户端和服务器连上了进行会调
    ws.onopen = function () {
        console.log("连接上了");
    }
    //当服务器向客户端发送消息时，执行此函数
    ws.onmessage = function (event) {
        console.log(event.data);
        $(".message").append("<li>"+event.data+"</li>");
    }
});
</script>
</html>